<style>.goods-detail {
    min-width: 200px;
}
.goods-detail .goods-info {
    width: auto;
    min-width: 120px;
    height: 72px;
}
.btn {
  display: inline-block;
  padding: 5px 8px;
  background-color: #fff;
  color: #333;
  text-decoration: none;
  border: 1px solid red;
  transition: background-color 0.3s ease;
}

</style>
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">共建订单</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <form id="form-search" class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/store/market.jointly.order/index">
                            <div class="am-u-sm-12 am-u-md-1">
                            <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="j-export am-btn am-btn-success am-radius"
                                                   href="{{:url('store/market.jointly.order/index')}}">
                                                    全部订单
                                                </a>
                                                      
                                        </div>
                                    </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-11">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <select name="r_payType"
                                                data-am-selected="{btnSize: 'sm', placeholder: '支付方式'}">
                                                    <option value="">全部</option>
                                                <option value="1" {{if input('r_payType')==1}} selected{{/if}}>线下支付</option>
                                                <option value="2" {{if input('r_payType')==2}} selected{{/if}}>线上支付</option>
                                           </select>
                                    </div>
                                    <div class="am-form-group am-fl">
                                            <select name="r_state"
                                                data-am-selected="{btnSize: 'sm', placeholder: '交易状态'}">
                                            <option value="">全部</option>
                                            <option value="10" {{if input('r_state')==10}} selected{{/if}}>正常</option>
                                            <option value="20" {{if input('r_state')==20}} selected{{/if}}>已支付</option>
                                            <option value="60" {{if input('r_state')==60}} selected{{/if}}>使用中</option>
                                            <option value="80" {{if input('r_state')==80}} selected{{/if}}>已使用已完成</option>
                                            </select>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="start_time"
                                               class="am-form-field"
                                               value="{{:input('start_time')}}" placeholder="请选择起始日期"
                                               data-am-datepicker>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="end_time"
                                               class="am-form-field"
                                               value="{{:input('end_time')}}" placeholder="请选择截止日期"
                                               data-am-datepicker>
                                    </div>
   
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search"
                                                   placeholder="请输入电话/用户姓名" value="{{:input('search')}}">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="order-list am-scrollable-horizontal am-u-sm-12 am-margin-top-xs">
                        <table width="100%" class="am-table am-table-centered
                        am-text-nowrap am-margin-bottom-xs">
                            <thead>
                            <tr>
                                <th>创建人</th>
                                <th style="width:35%;">项目信息</th>
                                <th>领取人</th>
                                <th>支付状态</th>
                                <th>交易状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php $colspan = 8; ?>
                            <?php if (!$list->isEmpty()): foreach ($list as $order): ?>
                                <tr class="order-empty">
                                    <td colspan="<?= $colspan ?>"></td>
                                </tr>
                                <tr>
                                    <td class="am-text-middle am-text-left" colspan="<?= $colspan ?>">
                                        <span class="am-margin-right-lg"> <?= $order['r_createtime'] ?></span>
                                        <span class="am-margin-right-lg">订单号：<?= $order['c_orderNo'] ?></span>
                                    </td>
                                </tr>
                   
                                    <tr>
									
										<td class="goods-detail am-text-middle">
										    <div class="goods-image" >
										        <img src="<?= $order['c_avatarUrl'] ?>" alt="" style="border-radius: 50%;">
										    </div>
										    <div class="goods-info">
										        <p class="goods-title">
													ID:<?= $order['c_uid'] ?><br><?= $order['c_nickName'] ?>
												</p>
										    </div>
										</td>
										
                                        <td class="goods-detail am-text-middle">
                                            <div class="goods-info">

                                                <p class="goods-title">
                                                <b><?= $order['u_project'] ?></b>
												</p>
                                                <p>领取总价格：<span style="color: red;">￥<?= $order['r_allPrice'] ?></span></p>
                                            </div>
                                        </td>

                                        

                                        <td class="goods-detail am-text-middle">
                                            <div class="goods-image">
												<?php if ($order['u_avatarUrl']!=''): ?>
													<img src="<?= $order['u_avatarUrl'] ?>" alt="" style="border-radius: 5px;">
												<?php endif; ?>
                                                
                                            </div>
                                            <div class="goods-info">
												<p class="goods-title">
													<?php if ($order['u_nickName']=='未领取'): ?>
														<span style="font-weight:bold;color:#F00;"><?= $order['u_nickName'] ?></span>
													<?php else: ?>
														<span style="font-weight:bold;color:#333;"><?= $order['u_nickName'] ?></span>
													<?php endif; ?>
													
													<span style="padding-left:10px;"><?= $order['u_trueName'] ?> （<?= $order['u_sex']==1?'男':'女' ?>）</span>
												</p>
                                                <p class="goods-title">
                                                电话：<?= $order['u_mobile'] ?>
												</p>
                                                <p class="goods-title">
                                                地址：<?= $order['u_address'] ?>
												</p>

                                                
                                            </div>
                                        </td>
                 
                                        <td class="am-text-middle">
                                            <p><?php 

                                            if($order['r_payType']==1){
                                                echo '线下支付<br>';
                                            }else if($order['r_payType']==2){
                                                echo '线上支付<br>';
                                            }
                    
                                            if($order['r_payState']==1){
                                                echo '未支付';
                                            }else if($order['r_payState']==8){
                                                echo '<span style="color: green;">支付成功</span>';
                                            }else if($order['r_payState']==4){
                                                echo ' <span style="color: red;">支付失败</span>';
                                            }else{
                                                echo '未知状态'.$order['r_payState'];
                                            }
                                            
                                             ?></p>
                                    
                                        </td>
                                        <td class="am-text-middle">

                                        <?php
                                         if($order['r_state']==10){
                                            echo '正常';
                                        }else if($order['r_state']==20){
                                            echo '已支付';
                                        }else if($order['r_state']==60){
                                            echo ' 使用中';
                                        }else if($order['r_state']==80){
                                            echo ' 已使用已完成';
                                        }else{
                                            echo '未知状态'.$order['r_state'];
                                        }?>
                                        </td>
                                        <td class="am-text-middle">
                                            <?php if($order['r_payState']==8){ ?>

                                                <?php if($order['r_state']==80){ 
                                                    echo '<span style="color: green;">已核销</span>';
                                                }else{ ?>
                                                

                                        <a class="btn confirm-writeoff" style="color:#F00;" data-url="<?php echo url('writeoff',['r_id'=>$order['r_id']])?>" href="javascript:;">
                                                 核销
                                         </a>
                                         <?php
                                                }
                                          }else{
                                            echo ' - ';
                                         } ?>
                                        </td>
                                       
                                    </tr>
                                <?php endforeach; ?>
                  
                                <tr>
                                    <td colspan="<?= $colspan ?>" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
   $(function () {

    $(".confirm-writeoff").click(function(){
        var url = $(this).data('url');
        layer.confirm('确认核销吗？', {
                btn: ['确定', '取消'] //按钮
            }, function(){
                $.post(url,{},function(res){
                    layer.msg(res.msg, {icon: res.code});
                    if(res.code==1){
                        location.reload();
                    }
                });
            }, function(){
                //取消
            });

        });
        return false;
    });



    $(function () {

        /**
         * 订单导出
         */
        $('.j-export').click(function () {
            var data = {};
            var formData = $('#form-search').serializeArray();
            $.each(formData, function () {
                this.name !== 's' && (data[this.name] = this.value);
            });
            window.location = "<?= url('order.operate/export') ?>" + '&' + $.urlEncode(data);
        });

    });

</script>

